# if语句
a,b=10,10
if a>b then # then可省
    p "a比b大"
elsif a==b then
    p "a比b中"
elsif a<b then
    p "a比b小"
else
    p "不知道"
end
# unless语句
unless a>b then
    p "a不比b小"
end

# case语句
tags=["A","B","CDE","12"]
tags.each do |tag|
    case tag
    when "A","B" then # then可省
        # when一次可指定多个值
        puts "#{tag} is a char."
    when "12" then 
        puts "#{tag} is a int."
    else 
        puts "#{tag} is a str."
    end
end
arr=["a",1,nil]
arr.each do |item|
    case item 
    when String 
        # case语句在判断when时使用 === (广义的相等，包括==,=~,instance of等)
        puts "Item #{item} is a String."
    when Numeric
        puts "Item #{item} is a Numeric."
    else
        puts "Item #{item} is something."
    end
end

# 修饰符if unless
puts "a=b" if a==b

#对象的同一性
ary1=["foo"]
ary2=["f","o","o"]
#使用object_i或者 __id__得到一个对象标识
print ary1.object_id," ",ary2.__id__,"\n" 
str1=ary1[0]
str2=ary2[0]+ary2[1]+ary2[2]
str3=str1
# equal?判断ID eql?判断值
print str1.equal?(str2),str1.eql?(str3)
#数值类重新定义eql?
print 1.eql?(1.0)